#!/bin/bash
# test cgconfigparser with multiple config files

. `dirname $0`/../testenv.sh

# prepare config files in a temporary directory
mkdir -p $TMP/conf.d
for i in $TESTDIR/tools/cgconfigparser/multiconfig/*.conf; do
	mv `prepare_config $i` $TMP/conf.d/
done

$TOOLSDIR/cgconfigparser -L $TMP/conf.d/ \
	|| die "cgconfigparser failed"

# check that all expected groups exist
$TOOLSDIR/lscgroup > $TMP/groups.out
grep "cpu,cpuacct:/1$" <$TMP/groups.out >/dev/null \
	|| die "cannot find group 1"
grep "freezer:/22$" <$TMP/groups.out >/dev/null \
	|| die "cannot find group 2"
grep "net_cls:/333$" <$TMP/groups.out >/dev/null \
	|| die "cannot find group 3"
grep "cpu,cpuacct:/1/4$" <$TMP/groups.out >/dev/null \
	|| die "cannot find group 1/4"
grep "freezer:/22/4$" <$TMP/groups.out >/dev/null \
	|| die "cannot find group 22/4"
grep "net_cls:/333/4$" <$TMP/groups.out >/dev/null \
	|| die "cannot find group 333/4"
grep "cpu,cpuacct:/5$" <$TMP/groups.out >/dev/null \
	|| die "cannot find group 5"
grep "freezer:/55$" <$TMP/groups.out >/dev/null \
	|| die "cannot find group 55"
grep "net_cls:/555$" <$TMP/groups.out >/dev/null \
	|| die "cannot find group 555"

# clear it at once
$TOOLSDIR/cgclear -e -L $TMP/conf.d/ \
	|| die "cgclear failed"

cleanup
exit 0
